package com.eeepay.eeepay_v2.util;

import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.provider.MediaStore;
import android.util.Log;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * Created by Ching on 2016/4/2615:14.
 */
public class BitmapUtils {

    public static Bitmap createBitmap(Context context, Uri uri, File imgFile) {
        Bitmap bitmap = null;
        FileOutputStream fos = null;
        Log.d("saki", " uri " + uri + " imgFile " + imgFile);
        try {
            bitmap = MediaStore.Images.Media.getBitmap(context.getContentResolver(), uri);
            fos = new FileOutputStream(imgFile);
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
            fos.flush();
            fos.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return bitmap;
    }
}

